import time
import os, sys
import wx
import vtk
import math
import numpy
import vtktudoss
try:
    import extended.BaseCalc as BaseCalc
except ImportError:
    import BaseCalc

def create(parent):
    return WidgetCollection(parent)
    
class WidgetCollection:
    def __init__(self, parent):
        print "WidgetCollection module loaded."        
        self.parent = parent
        self.baseCalc = BaseCalc.create(self, self)
        self.InitializeWidgets()
              
    def InitializeWidgets(self):
        xoffset = [-5.5, 0.0, 0]
        yoffset = [0.0, 5.5, 0]
        zoffset = [0.0, 0.0, 5.5]
        
        widgetscale = 6
        modelfilename = os.path.join(self.parent.appdir, "jointnudge.stl")
        
        #Spine elevation
        self.spineWidget_elevation = vtktudoss.vtkAdvancedAngleWidget()       
        self.spineWidget_elevation.SetFileName(modelfilename)
        self.spineWidget_elevation.KeyPressActivationOff()
        self.spineWidget_elevation.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.spineWidget_elevation.SetInteractor(self.parent.renwini1)        
        self.spineWidget_elevation.Setaxis_length(0.8)
        self.spineWidget_elevation.SetshowContext(False)
        self.spineWidget_elevation.SetColor(self.parent.ren1overlay.spineact.GetProperty().GetColor())
        self.spineWidget_elevation.PlaceWidget()        
        self.spineWidget_elevation.SetScale(widgetscale)        
        self.spineWidget_elevation.Setmirrorfonts(-1.0)
        self.spineWidget_elevation.SetInitialAxis([1.0,0.0,0.0])
        #~ self.spineWidget_elevation.Rotate(90.0, [0,1,0])
        self.spineWidget_elevation.Setposoffset(xoffset)
        position = self.parent.ren1overlay.spineact.GetPosition()
        self.spineWidget_elevation.SetInitialPosition(position)
        self.spineWidget_elevation.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.spineWidget_elevation.SetLabelsEnabled(1)
        
        #Spine plane
        self.spineWidget_plane = vtktudoss.vtkAdvancedAngleWidget()
        self.spineWidget_plane.SetFileName(modelfilename)        
        self.spineWidget_plane.KeyPressActivationOff()
        self.spineWidget_plane.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.spineWidget_plane.SetInteractor(self.parent.renwini1)
        self.spineWidget_plane.Setaxis_length(0.8)
        self.spineWidget_plane.SetshowContext(False)
        self.spineWidget_plane.SetColor(self.parent.ren1overlay.spineact.GetProperty().GetColor())
        self.spineWidget_plane.PlaceWidget()        
        self.spineWidget_plane.SetScale(widgetscale)        
        self.spineWidget_plane.SetInitialAxis([0.0,-1.0,0.0])
        self.spineWidget_plane.Rotate(90.0, [1,0,0])
        self.spineWidget_plane.Setposoffset(zoffset)   
        position = self.parent.ren1overlay.spineact.GetPosition()
        self.spineWidget_plane.SetInitialPosition(position)
        self.spineWidget_plane.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.spineWidget_plane.SetLabelsEnabled(1)
        
        #Spine axial
        self.spineWidget_axial = vtktudoss.vtkAdvancedAngleWidget()
        self.spineWidget_axial.SetFileName(modelfilename)        
        self.spineWidget_axial.KeyPressActivationOff()
        self.spineWidget_axial.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.spineWidget_axial.SetInteractor(self.parent.renwini1)
        self.spineWidget_axial.Setaxis_length(0.8)
        self.spineWidget_elevation.SetshowContext(False)
        self.spineWidget_axial.SetColor(self.parent.ren1overlay.spineact.GetProperty().GetColor())
        self.spineWidget_axial.PlaceWidget()        
        self.spineWidget_axial.SetScale(widgetscale)
        self.spineWidget_axial.SetInitialAxis([0.0,1.0,0.0])
        self.spineWidget_axial.Setposoffset(yoffset)   
        position = self.parent.ren1overlay.spineact.GetPosition()
        self.spineWidget_axial.SetInitialPosition(position)
        self.spineWidget_axial.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.spineWidget_axial.SetLabelsEnabled(1)
        
        #clavicle elevation
        self.clavicleWidget_elevation = vtktudoss.vtkAdvancedAngleWidget()        
        self.clavicleWidget_elevation.SetFileName(modelfilename)
        self.clavicleWidget_elevation.KeyPressActivationOff()
        self.clavicleWidget_elevation.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.clavicleWidget_elevation.SetInteractor(self.parent.renwini1)        
        self.clavicleWidget_elevation.Setaxis_length(0.8)
        self.clavicleWidget_elevation.SetshowContext(False)
        self.clavicleWidget_elevation.SetColor(self.parent.ren1overlay.clavact.GetProperty().GetColor())
        self.clavicleWidget_elevation.PlaceWidget()        
        self.clavicleWidget_elevation.SetScale(widgetscale)
        self.clavicleWidget_elevation.Setmirrorfonts(-1.0)
        self.clavicleWidget_elevation.SetInitialAxis([1.0,0.0,0.0])
        #~ self.clavicleWidget_elevation.Rotate(90.0, [0,1,0])
        self.clavicleWidget_elevation.Setposoffset(xoffset)
        position = self.parent.ren1overlay.clavact.GetPosition()
        self.clavicleWidget_elevation.SetInitialPosition(position)
        self.clavicleWidget_elevation.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.clavicleWidget_elevation.SetLabelsEnabled(1)
        
        #clavicle plane
        self.clavicleWidget_plane = vtktudoss.vtkAdvancedAngleWidget()
        self.clavicleWidget_plane.SetFileName(modelfilename)
        self.clavicleWidget_plane.KeyPressActivationOff()
        self.clavicleWidget_plane.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.clavicleWidget_plane.SetInteractor(self.parent.renwini1)
        self.clavicleWidget_plane.Setaxis_length(0.8)
        self.clavicleWidget_plane.SetshowContext(False)
        self.clavicleWidget_plane.SetColor(self.parent.ren1overlay.clavact.GetProperty().GetColor())
        self.clavicleWidget_plane.PlaceWidget()        
        self.clavicleWidget_plane.SetScale(widgetscale)        
        self.clavicleWidget_plane.SetInitialAxis([0.0,-1.0,0.0])
        self.clavicleWidget_plane.Rotate(90.0, [1,0,0])
        self.clavicleWidget_plane.Setposoffset(zoffset)   
        position = self.parent.ren1overlay.clavact.GetPosition()
        self.clavicleWidget_plane.SetInitialPosition(position)
        self.clavicleWidget_plane.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.clavicleWidget_plane.SetLabelsEnabled(1)
        
        #clavicle axial
        self.clavicleWidget_axial = vtktudoss.vtkAdvancedAngleWidget()
        self.clavicleWidget_axial.SetFileName(modelfilename)
        self.clavicleWidget_axial.KeyPressActivationOff()
        self.clavicleWidget_axial.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.clavicleWidget_axial.SetInteractor(self.parent.renwini1)
        self.clavicleWidget_axial.Setaxis_length(0.8)
        self.clavicleWidget_axial.SetshowContext(False)
        self.clavicleWidget_axial.SetColor(self.parent.ren1overlay.clavact.GetProperty().GetColor())
        self.clavicleWidget_axial.PlaceWidget()
        self.clavicleWidget_axial.SetScale(widgetscale)        
        self.clavicleWidget_axial.SetInitialAxis([0.0,1.0,0.0])
        self.clavicleWidget_axial.Setposoffset(yoffset)     
        position = self.parent.ren1overlay.clavact.GetPosition()
        self.clavicleWidget_axial.SetInitialPosition(position)
        self.clavicleWidget_axial.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.clavicleWidget_axial.SetLabelsEnabled(1)        
        
        #scapula elevation
        self.scapulaWidget_elevation = vtktudoss.vtkAdvancedAngleWidget() 
        self.scapulaWidget_elevation.SetFileName(modelfilename)        
        self.scapulaWidget_elevation.KeyPressActivationOff()
        self.scapulaWidget_elevation.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.scapulaWidget_elevation.SetInteractor(self.parent.renwini1)        
        self.scapulaWidget_elevation.Setaxis_length(0.8)
        self.scapulaWidget_elevation.SetshowContext(False)
        self.scapulaWidget_elevation.SetColor(self.parent.ren1overlay.scapact.GetProperty().GetColor())        
        self.scapulaWidget_elevation.PlaceWidget()             
        self.scapulaWidget_elevation.SetScale(widgetscale)
        self.scapulaWidget_elevation.Setmirrorfonts(-1.0)
        self.scapulaWidget_elevation.SetInitialAxis([1.0,0.0,0.0])
        #~ self.scapulaWidget_elevation.Rotate(90.0, [0,1,0])
        self.scapulaWidget_elevation.Setposoffset(xoffset)
        position = self.parent.ren1overlay.scapact.GetPosition()
        self.scapulaWidget_elevation.SetInitialPosition(position)
        self.scapulaWidget_elevation.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.scapulaWidget_elevation.SetLabelsEnabled(1)
        
        
        #scapula plane
        self.scapulaWidget_plane = vtktudoss.vtkAdvancedAngleWidget()
        self.scapulaWidget_plane.SetFileName(modelfilename)
        self.scapulaWidget_plane.KeyPressActivationOff()
        self.scapulaWidget_plane.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.scapulaWidget_plane.SetInteractor(self.parent.renwini1)
        self.scapulaWidget_plane.Setaxis_length(0.8)
        self.scapulaWidget_plane.SetshowContext(False)
        self.scapulaWidget_plane.SetColor(self.parent.ren1overlay.scapact.GetProperty().GetColor())
        self.scapulaWidget_plane.PlaceWidget()        
        self.scapulaWidget_plane.SetScale(widgetscale)
        self.scapulaWidget_plane.SetInitialAxis([0.0,-1.0,0.0])
        self.scapulaWidget_plane.Rotate(90.0, [1,0,0])
        self.scapulaWidget_plane.Setposoffset(zoffset)     
        position = self.parent.ren1overlay.scapact.GetPosition()
        self.scapulaWidget_plane.SetInitialPosition(position)
        self.scapulaWidget_plane.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.scapulaWidget_plane.SetLabelsEnabled(1)
        
        #scapula axial
        self.scapulaWidget_axial = vtktudoss.vtkAdvancedAngleWidget()
        self.scapulaWidget_axial.SetFileName(modelfilename)
        self.scapulaWidget_axial.KeyPressActivationOff()
        self.scapulaWidget_axial.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.scapulaWidget_axial.SetInteractor(self.parent.renwini1)
        self.scapulaWidget_axial.Setaxis_length(0.8)
        self.scapulaWidget_axial.SetshowContext(False)
        self.scapulaWidget_axial.SetColor(self.parent.ren1overlay.scapact.GetProperty().GetColor())
        self.scapulaWidget_axial.PlaceWidget()
        self.scapulaWidget_axial.SetScale(widgetscale)
        self.scapulaWidget_axial.SetInitialAxis([0.0,1.0,0.0])
        self.scapulaWidget_axial.Setposoffset(yoffset)     
        position = self.parent.ren1overlay.scapact.GetPosition()
        self.scapulaWidget_axial.SetInitialPosition(position)
        self.scapulaWidget_axial.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.scapulaWidget_axial.SetLabelsEnabled(1)
        
        #GH elevation
        self.GHWidget_elevation = vtktudoss.vtkAdvancedAngleWidget()    
        self.GHWidget_elevation.SetFileName(modelfilename)
        self.GHWidget_elevation.KeyPressActivationOff()
        self.GHWidget_elevation.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.GHWidget_elevation.SetInteractor(self.parent.renwini1)        
        self.GHWidget_elevation.Setaxis_length(0.8)        
        self.GHWidget_elevation.SetshowContext(False)
        self.GHWidget_elevation.SetColor(self.parent.ren1overlay.GHact.GetProperty().GetColor())
        self.GHWidget_elevation.PlaceWidget()        
        self.GHWidget_elevation.SetScale(widgetscale)
        self.GHWidget_elevation.Setmirrorfonts(-1.0)
        self.GHWidget_elevation.SetInitialAxis([1.0,0.0,0.0])
        #~ self.GHWidget_elevation.Rotate(90.0, [0,1,0])
        self.GHWidget_elevation.Setposoffset(xoffset)        
        position = self.parent.ren1overlay.GHact.GetPosition()
        self.GHWidget_elevation.SetInitialPosition(position)
        self.GHWidget_elevation.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.GHWidget_elevation.SetLabelsEnabled(1)
        
        #GH plane
        self.GHWidget_plane = vtktudoss.vtkAdvancedAngleWidget()
        self.GHWidget_plane.SetFileName(modelfilename)
        self.GHWidget_plane.KeyPressActivationOff()
        self.GHWidget_plane.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.GHWidget_plane.SetInteractor(self.parent.renwini1)
        self.GHWidget_plane.PlaceWidget()
        self.GHWidget_plane.Setaxis_length(0.8)
        self.GHWidget_plane.SetshowContext(False)
        self.GHWidget_plane.SetColor(self.parent.ren1overlay.GHact.GetProperty().GetColor())
        self.GHWidget_plane.SetScale(widgetscale)
        self.GHWidget_plane.SetInitialAxis([0.0,-1.0,0.0])
        self.GHWidget_plane.Rotate(90.0, [1,0,0])
        self.GHWidget_plane.Setposoffset(zoffset)
        position =self.parent.ren1overlay.GHact.GetPosition()
        self.GHWidget_plane.SetInitialPosition(position)
        self.GHWidget_plane.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.GHWidget_plane.SetLabelsEnabled(1)
        
        #GH axial
        self.GHWidget_axial = vtktudoss.vtkAdvancedAngleWidget()
        self.GHWidget_axial.SetFileName(modelfilename)
        self.GHWidget_axial.KeyPressActivationOff()
        self.GHWidget_axial.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.GHWidget_axial.SetInteractor(self.parent.renwini1)
        self.GHWidget_axial.Setaxis_length(0.8)
        self.GHWidget_axial.SetshowContext(False)
        self.GHWidget_axial.SetColor(self.parent.ren1overlay.GHact.GetProperty().GetColor())
        self.GHWidget_axial.PlaceWidget()
        self.GHWidget_axial.SetScale(widgetscale)        
        self.GHWidget_axial.SetInitialAxis([0.0,1.0,0.0])
        position = self.parent.ren1overlay.GHact.GetPosition()
        self.GHWidget_axial.Setposoffset(yoffset)
        self.GHWidget_axial.SetInitialPosition(position)
        self.GHWidget_axial.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.GHWidget_axial.SetLabelsEnabled(1)
        
        #EL elevation
        self.ELWidget_elevation = vtktudoss.vtkAdvancedAngleWidget()
        self.ELWidget_elevation.SetFileName(modelfilename)        
        self.ELWidget_elevation.KeyPressActivationOff()
        self.ELWidget_elevation.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.ELWidget_elevation.SetInteractor(self.parent.renwini1)        
        self.ELWidget_elevation.Setaxis_length(0.8)
        self.ELWidget_elevation.SetshowContext(False)
        self.ELWidget_elevation.SetColor(self.parent.ren1overlay.ELact.GetProperty().GetColor())
        self.ELWidget_elevation.PlaceWidget()        
        self.ELWidget_elevation.SetScale(widgetscale)
        self.ELWidget_elevation.Setmirrorfonts(-1.0)
        self.ELWidget_elevation.SetInitialAxis([1.0,0.0,0.0])
        #~ self.ELWidget_elevation.Rotate(90.0, [0,1,0])
        self.ELWidget_elevation.Setposoffset(xoffset)
        position = self.parent.ren1overlay.ELact.GetPosition()
        self.ELWidget_elevation.SetInitialPosition(position)
        self.ELWidget_elevation.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.ELWidget_elevation.SetLabelsEnabled(1)
        
        #EL plane
        self.ELWidget_plane = vtktudoss.vtkAdvancedAngleWidget()
        self.ELWidget_plane.SetFileName(modelfilename)        
        self.ELWidget_plane.KeyPressActivationOff()
        self.ELWidget_plane.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.ELWidget_plane.SetInteractor(self.parent.renwini1)
        self.ELWidget_plane.PlaceWidget()
        self.ELWidget_plane.Setaxis_length(0.8)
        self.spineWidget_elevation.SetshowContext(False)
        self.ELWidget_plane.SetColor(self.parent.ren1overlay.ELact.GetProperty().GetColor())
        self.ELWidget_plane.SetScale(widgetscale)
        self.ELWidget_plane.SetInitialAxis([0.0,-1.0,0.0])
        self.ELWidget_plane.Rotate(90.0, [1,0,0])
        self.ELWidget_plane.Setposoffset(zoffset)
        position = self.parent.ren1overlay.ELact.GetPosition()
        self.ELWidget_plane.SetInitialPosition(position)
        self.ELWidget_plane.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.ELWidget_plane.SetLabelsEnabled(1)
        
        #EL axial
        self.ELWidget_axial = vtktudoss.vtkAdvancedAngleWidget()
        self.ELWidget_axial.SetFileName(modelfilename)
        self.ELWidget_axial.KeyPressActivationOff()
        self.ELWidget_axial.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.ELWidget_axial.SetInteractor(self.parent.renwini1)
        self.ELWidget_axial.Setaxis_length(0.8)
        self.ELWidget_axial.SetshowContext(False)
        self.ELWidget_axial.SetColor(self.parent.ren1overlay.ELact.GetProperty().GetColor())
        self.ELWidget_axial.PlaceWidget()
        self.ELWidget_axial.SetScale(widgetscale)
        self.ELWidget_axial.SetInitialAxis([0.0,1.0,0.0])
        self.ELWidget_axial.Setposoffset(yoffset)
        position = self.parent.ren1overlay.ELact.GetPosition()
        self.ELWidget_axial.SetInitialPosition(position)
        self.ELWidget_axial.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.ELWidget_axial.SetLabelsEnabled(1)
        
        #HUM THORAX ELEVATION
        self.GHGlobal_elevation = vtktudoss.vtkAdvancedAngleWidget()
        self.GHGlobal_elevation.SetFileName(modelfilename)
        self.GHGlobal_elevation.KeyPressActivationOff()
        self.GHGlobal_elevation.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.GHGlobal_elevation.SetInteractor(self.parent.renwini1)
        self.GHGlobal_elevation.Setaxis_length(4.2)
        self.GHGlobal_elevation.SetshowContext(False)
        self.GHGlobal_elevation.SetColor(self.parent.ren1overlay.GHact.GetProperty().GetColor())
        self.GHGlobal_elevation.PlaceWidget()        
        self.GHGlobal_elevation.SetScale(widgetscale)
        self.GHGlobal_elevation.Setpiechart(False)
        self.GHGlobal_elevation.Setmirrorfonts(-1.0)
        self.GHGlobal_elevation.SetInitialAxis([1.0,0.0,0.0])
        #~ self.GHGlobal_elevation.Rotate(90.0, [0,1,0])
        self.GHGlobal_elevation.Setposoffset([-3.5, 0.0, 0])
        position =self.parent.ren1overlay.GHact.GetPosition()
        self.GHGlobal_elevation.SetInitialPosition(position)
        self.GHGlobal_elevation.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.GHGlobal_elevation.SetLabelsEnabled(1)
        
        self.GHGlobal_plane = vtktudoss.vtkAdvancedAngleWidget()
        self.GHGlobal_plane.SetFileName(modelfilename)
        self.GHGlobal_plane.KeyPressActivationOff()
        self.GHGlobal_plane.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.GHGlobal_plane.SetInteractor(self.parent.renwini1)
        self.GHGlobal_plane.Setaxis_length(4.2)
        self.GHGlobal_plane.SetshowContext(False)
        self.GHGlobal_plane.SetColor(self.parent.ren1overlay.GHact.GetProperty().GetColor())
        self.GHGlobal_plane.PlaceWidget()        
        self.GHGlobal_plane.SetScale(widgetscale)
        self.GHGlobal_plane.Setpiechart(False)
        self.GHGlobal_plane.SetInitialAxis([0.0,-1.0,0.0])
        self.GHGlobal_plane.Rotate(90.0, [1,0,0])        
        position = self.parent.ren1overlay.GHact.GetPosition()
        self.GHGlobal_plane.Setposoffset([0.0, 0.0, 3.5])
        self.GHGlobal_plane.SetInitialPosition(position)
        self.GHGlobal_plane.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.GHGlobal_plane.SetLabelsEnabled(1)        
        
        self.GHGlobal_axial = vtktudoss.vtkAdvancedAngleWidget()
        self.GHGlobal_axial.SetFileName(modelfilename)
        self.GHGlobal_axial.KeyPressActivationOff()
        self.GHGlobal_axial.SetInput(self.parent.torsiactor.GetMapper().GetInput())
        self.GHGlobal_axial.SetInteractor(self.parent.renwini1)
        self.GHGlobal_axial.Setaxis_length(4.2)
        self.GHGlobal_axial.SetshowContext(False)
        self.GHGlobal_axial.SetColor(self.parent.ren1overlay.GHact.GetProperty().GetColor())
        self.GHGlobal_axial.PlaceWidget()        
        self.GHGlobal_axial.SetScale(widgetscale)
        self.GHGlobal_axial.Setpiechart(False)
        self.GHGlobal_axial.SetInitialAxis([0.0,1.0,0.0])
        position =self.parent.ren1overlay.GHact.GetPosition()
        self.GHGlobal_axial.Setposoffset([0.0, 3.5, 0.0])
        self.GHGlobal_axial.SetInitialPosition(position)
        self.GHGlobal_axial.AddObserver("InteractionEvent",self.ArcWidgetModified)
        self.GHGlobal_axial.SetLabelsEnabled(1)
        

        
    def EnableWidgets(self):
        self.arcWidget.EnabledOn()
        self.axialWidget1.EnabledOn()
        self.arcWidget2.EnabledOn()
        self.arcWidget3.EnabledOn()
        self.arcWidget4.EnabledOn()
        
    def DisableWidgets(self):
        self.arcWidget.EnabledOff()
        self.axialWidget1.EnabledOff()
        self.arcWidget2.EnabledOff()
        self.arcWidget3.EnabledOff()
        self.arcWidget4.EnabledOff()
        
    def UpdateWidgets(self):
        for i in self.parent.parent.Filters.filteredAngles:            
            for filter in self.parent.parent.Filters.jointAngleCollection:
                if filter['stanceID'] == i:
                    if filter['min1'] != None:
                        filter['widget'].SetWidgetRange1(filter['min1'], filter['max1'])
                    if filter['min2'] != None:
                        filter['widget'].SetWidgetRange2(filter['min2'], filter['max2'])
                    filter['widget'].UpdateRangeIndicators()
        self.parent.parent.Filters.UpdateShaderOpacity()
                
    def ArcWidgetModified(self, caller, event): 
        Filters = self.parent.parent.Filters
        for i in range(0, len(Filters.jointAngleCollection)):
            try:
                Filters.jointAngleCollection[i]['filter_min'] = Filters.jointAngleCollection[i]['widget'].GetfilterRangeMin()
                Filters.jointAngleCollection[i]['filter_max'] = Filters.jointAngleCollection[i]['widget'].GetfilterRangeMax()
                ##~ print "filters: ", self.jointAngleCollection[i]['filter_min'], ' - ',self.jointAngleCollection[i]['filter_max']
            except AttributeError:
                ##print "no widget defined"
                pass
        self.parent.kdtree_modified = True
        Filters.RestartFiltering()
        Filters.RestartFilteringReferences()            
    
    
    